/**
 * Created by wangshuyi on 2016/12/27.
 */

'use strict';

/**
 * 公众号
 */

const uuid = require('uuid');
const mongoose = require('../util/mongoDB'),
    Schema = mongoose.Schema;
const config = require('../../config/config');

const schema = new Schema({
    _id : {type : String, default: uuid.v4},
    code : { type: String, default: uuid.v4},       //编码

    customer:{type:String},                          //抽奖用户
    counter:{type:Number,default:1},                           //抽奖次数
    eventId:{type:String,ref: "PrizeEvent"},       //参加活动
    officialAccount : { type: String,ref:"OfficialAccount"},            //所属公众号
    vipName:{type:String},                           //会员名称
    cardCode:{type:String},
    mobile:{type:String},
    state : { type: Number, default : 1},           //是否有效
    createTime: {type: Date, default: Date.now},    //创建时间
    creater: {type: String, ref : "User", default: config.dbUser.robot._id},          //创建者
    updateTime : { type: Date, default: Date.now},  //最后更新时间
    updater : { type: String, ref : "User", default: config.dbUser.robot._id}         //最后更新者
});

const model = mongoose.model('PrizeCount',schema);


module.exports = model;
